package com.zzb.learning.api;


import com.zzb.base.model.RestResponse;
import com.zzb.learning.service.LearningService;
import com.zzb.learning.util.SecurityUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Mr.M
 * @version 1.0
 * @description 我的学习接口
 * @date 2022/10/27 8:59
 */
@Api(value = "学习过程管理接口", tags = "学习过程管理接口")
@Slf4j
@RestController
public class LearningController {
    @Autowired
    private LearningService learningService;

    /**
     * 获取视频
     * @param courseId  课程编号
     * @param teachplanId  课程计划编号
     * @param mediaId   媒资编号
     * @return
     */
    @ApiOperation("获取视频")
    @GetMapping("/open/learn/getvideo/{courseId}/{teachplanId}/{mediaId}")
    public RestResponse<String> getVideo(@PathVariable("courseId") Long courseId, @PathVariable("teachplanId") Long teachplanId, @PathVariable("mediaId") String mediaId) {
        //获取登录用户
        SecurityUtil.XcUser xcUser = SecurityUtil.getUser();
        if (xcUser == null){
            return RestResponse.fail("请先登录");
        }
        //获取userId
        String userId = xcUser.getId();
        return learningService.getVideo(userId, courseId, teachplanId, mediaId);
    }

}
